/* Copyright 2019 The Chromium Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* These forced colors mode styles override the default styling for HTML
 * elements as defined in core/html/resources/html.css when forced colors mode
 * is enabled.
 */

/* This sheet is appended to html.css before parsing which means the selectors
   below are in the default html namespace:

   @namespace "http://www.w3.org/1999/xhtml"
*/

@media ua-forced-colors {
  :focus-visible {
    -internal-forced-outline-color: Highlight;
  }

  a:link,
  a:-webkit-any-link:active {
    -internal-forced-color: LinkText;
  }

  a:visited {
    -internal-forced-color: VisitedText;
  }

  fieldset {
    -internal-forced-border-color: CanvasText;
  }

  mark {
    -internal-forced-background-color: yellow;
    -internal-forced-color: black;
  }

  ::placeholder {
    -internal-forced-color: GrayText;
  }

  input,
  textarea {
    background-color: Canvas;
    -internal-forced-background-color: Canvas;
    -internal-forced-border-color: ButtonText;
    -internal-forced-color: CanvasText;
  }

  input:hover,
  textarea:hover,
  input[type="file"]:hover::-webkit-file-upload-button,
  input:focus,
  textarea:focus {
    -internal-forced-border-color: Highlight;
  }

  input[type="text"]:disabled,
  input[type="password"]:disabled,
  input[type="email"]:disabled,
  input[type="number"]:disabled,
  input[type="tel"]:disabled,
  input[type="url"]:disabled,
  input[type="search"]:disabled,
  input[type="date"]:disabled,
  input[type="month"]:disabled,
  input[type="week"]:disabled,
  input[type="time"]:disabled,
  input[type="datetime-local"]:disabled,
  textarea:disabled {
    background-color: ButtonFace;
    -internal-forced-background-color: ButtonFace;
    -internal-forced-border-color: GrayText;
    -internal-forced-color: GrayText;
  }

  input::-webkit-calendar-picker-indicator {
    background-color: ButtonFace;
    -internal-forced-background-color: ButtonFace;
    -internal-forced-color: ButtonText;
  }

  input::-webkit-datetime-edit-ampm-field:focus,
  input::-webkit-datetime-edit-day-field:focus,
  input::-webkit-datetime-edit-hour-field:focus,
  input::-webkit-datetime-edit-millisecond-field:focus,
  input::-webkit-datetime-edit-minute-field:focus,
  input::-webkit-datetime-edit-month-field:focus,
  input::-webkit-datetime-edit-second-field:focus,
  input::-webkit-datetime-edit-week-field:focus,
  input::-webkit-datetime-edit-year-field:focus {
      background-color: Highlight;
      outline: none;
      -internal-forced-background-color: Highlight;
      -internal-forced-color: HighlightText;
  }

  input[type="color"]:disabled {
    border-color: GrayText;
  }

  input[type="color"] {
    forced-color-adjust: none;
  }

  input[type="color"]::-webkit-color-swatch {
    border-color: CanvasText !important;
  }

  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  input[type="file"]::-webkit-file-upload-button {
    background-color: ButtonFace;
    -internal-forced-background-color: ButtonFace;
    -internal-forced-border-color: ButtonText;
    -internal-forced-color: ButtonText;
  }

  button:hover,
  input[type="button"]:hover,
  input[type="submit"]:hover,
  input[type="reset"]:hover,
  button:focus,
  input[type="button"]:focus,
  input[type="submit"]:focus,
  input[type="reset"]:focus {
    -internal-forced-border-color: Highlight;
  }

  button:disabled,
  input[type="button"]:disabled,
  input[type="submit"]:disabled,
  input[type="reset"]:disabled {
    -internal-forced-border-color: GrayText;
    -internal-forced-color: GrayText;
  }

  /* same color as hyperlinks */
  details summary {
    -internal-forced-color: LinkText;
  }

  select:-internal-list-box {
    background-color: Canvas !important;
    -internal-forced-background-color: Canvas !important;
    -internal-forced-border-color: ButtonText;
  }

  /* option disabled */
  select:-internal-list-box option:disabled,
  select:-internal-list-box option:disabled:hover,
  select:-internal-list-box:disabled option,
  select:-internal-list-box:disabled option:hover {
    background-color: Canvas !important;
    -internal-forced-background-color: Canvas !important;
    color: GrayText !important;
  }

  /* option selected */
  select:-internal-list-box:focus option:checked,
  select:-internal-list-box:focus option:checked:hover,
  select:-internal-list-box:focus option:checked:enabled:hover,
  select:-internal-list-box option:checked,
  select:-internal-list-box option:checked:hover,
  select:-internal-list-box:enabled option:checked:enabled:hover {
    background-color: Highlight !important;
    color: Canvas !important;
    forced-color-adjust: none;
  }

  /* option both disabled and selected */
  select:-internal-list-box:focus option:checked:disabled,
  select:-internal-list-box:focus option:checked:disabled:hover,
  select:-internal-list-box:disabled option:checked,
  select:-internal-list-box:disabled option:checked:hover,
  select:-internal-list-box option:checked:disabled,
  select:-internal-list-box option:checked:disabled:hover {
    background-color: GrayText !important;
    color: Canvas !important;
    forced-color-adjust: none;
  }

  select:-internal-list-box option:hover {
    background-color: Highlight !important;
    color: Canvas;
    forced-color-adjust: none;
  }

  select {
    background-color: Canvas;
    -internal-forced-background-color: Canvas;
    -internal-forced-border-color: CanvasText;
    -internal-forced-color: CanvasText;
  }

  select:not(:-internal-list-box) {
    background-color: Canvas;
    -internal-forced-background-color: Canvas;
  }

  select:hover {
    -internal-forced-border-color: Highlight;
  }

  select:focus {
    -internal-forced-border-color: Highlight;
  }

  select:disabled {
    opacity: 1;
    -internal-forced-border-color: GrayText;
    -internal-forced-color: GrayText;
  }

  meter::-webkit-meter-bar {
    background-color: ButtonFace;
    -internal-forced-background-color: ButtonFace;
    -internal-forced-border-color: CanvasText;
  }

  meter::-webkit-meter-even-less-good-value,
  meter::-webkit-meter-optimum-value,
  meter::-webkit-meter-suboptimum-value {
    background-color: Highlight;
    -internal-forced-background-color: Highlight;
  }

  input:-internal-autofill-previewed,
  textarea:-internal-autofill-previewed,
  select:-internal-autofill-previewed {
    background-color: Canvas !important;
    -internal-forced-background-color: Canvas !important;
    -internal-forced-color: CanvasText !important;
  }

  input:-internal-autofill-selected,
  textarea:-internal-autofill-selected,
  select:-internal-autofill-selected {
    background-color: Canvas !important;
    -internal-forced-background-color: Canvas !important;
    -internal-forced-color: CanvasText !important;
  }

}
